﻿using Oracle.DataAccess.Client;
using System;
using System.Data;
using WorkFlow.DBProxy;

namespace WorkFlow.web
{
    public partial class login : System.Web.UI.Page
    {
        /// <summary>
        /// 取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnCancel_Click(object sender, EventArgs e)
        {
            txtPwd.Text = "";
            txtAccount.Text = "";
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            OracleParameter[] orc = new OracleParameter[2] { new OracleParameter(":f_id", txtAccount.Text.Trim()), new OracleParameter(":f_pwd", txtPwd.Text.Trim()) };
            DataTable dt = DB.MapToDataTable(@"select F_ID ,f_identifier ,f_name  from t_users  where f_id=:f_id and f_pwd=:f_pwd", orc);
            if (dt != null && dt.Rows.Count > 0)
            {
                Session["USERID"] = dt.Rows[0]["F_ID"];
                Response.Redirect("Desktop.aspx");
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "failure", "alert(\"账号或密码错误!\")", true);
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            AjaxPro.Utility.RegisterTypeForAjax(this.GetType(), this.Page);
        }
    }
}